﻿using CefSharp;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tools
{
    public partial class Other : Form
    {
        public Other()
        {
            InitializeComponent();

            CefSettings settings = new CefSettings();
            Cef.Initialize(settings);

            Load("百度翻译", "https://fanyi.baidu.com");
            Load("Json格式化", "https://www.bejson.com/json/format/");
            Load("正则表达式", "https://regex101.com/");
            Load("Url解码", "https://tool.chinaz.com/tools/urlencode.aspx");
            Load("在线对比", "https://www.jq22.com/textDifference");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tabPage"></param>
        /// <param name="title"></param>
        /// <param name="url"></param>
        private void Load(string title, string url)
        {
            var tab = new TabPage();
            tab.Text = title;            
            this.tabControl1.Controls.Add(tab);

            var chromeBrowser = new ChromiumWebBrowser(url);

            tab.Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;

            BrowserSettings browserSettings = new BrowserSettings();
            chromeBrowser.BrowserSettings = browserSettings; 
        }
    }
}
